/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Hua YY
 * Date: 2024-09-19
 * Time: 19:18
 */
public class ThreadDemon12 {
    /*private static boolean isQuit = false;*/
    static boolean isQuit = false;
    public static void main(String[] args) throws InterruptedException {

        Thread t1 = new Thread(()->{
            while(!isQuit){
                try {
                    Thread.sleep(500);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
                System.out.println("t1线程正在运行");
            }
        });
        t1.start();
        Thread.sleep(2001);
        isQuit = true;
        System.out.println("终止t1线程");

    }

}
